import { ElMessageBox } from "element-plus";

/**
 * 消息弹出框
 * @param tip 提示消息
 * @param title 提示标提
 * @param callback 确认的回调
 * @param catchBack 取消的回调
 */
export const promiseConfirmTip = (tip: string, title: string = "提示") => {
	 return new Promise(resolve => {
	ElMessageBox.confirm(tip, title, {
		confirmButtonText: "确认",
		cancelButtonText: "退出",
		dangerouslyUseHTMLString: true
	}).then(()=>{
		resolve(true);
		}).catch(()=>{
		resolve(false);
		})
	});
};

/**
 * 消息弹出框
 * @param tip 提示消息
 * @param title 提示标提
 * @param callback 确认的回调
 * @param catchBack 取消的回调
 */
export const confirmTip = (tip: string, title: string = "提示", callback: any, catchBack?: any) => {
	ElMessageBox.confirm(tip, title, {
		confirmButtonText: "确认",
		cancelButtonText: "退出",
		dangerouslyUseHTMLString: true
	})
		.then(callback)
		.catch(catchBack);
};

/**
 * 提交内容弹框
 * @param tip 提示消息
 * @param title 提示标提
 * @param callback 确认的回调 回调函数的参数是一个对象 获取提交值 参数命.value
 * @param catchBack 取消的回调
 */
export const promptTip = (tip: string, title: string, callback: any, catchBack?: any) => {
	ElMessageBox.prompt(tip, title, {
		dangerouslyUseHTMLString: true,
		confirmButtonText: "确认",
		cancelButtonText: "退出"
	})
		.then(callback)
		.catch(catchBack);
};

/**
 * 提交内容弹框
 * @param tip 提示消息
 * @param title 提示标提
 * @param callback 确认的回调
 */
export const alertTip = (tip: string, title: string, callback: any) => {
	ElMessageBox.alert(tip, title, {
		confirmButtonText: "确认",
		callback: callback
	});
};
